#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
LL dis[N], f[N][21], v[N][21];
LL res[N];
LL p[N];
LL n, m;
LL find(LL x)
{
	if (x != p[x])p[x] = find(p[x]);
	return p[x];
}
struct node
{
	LL a, b, v, id;
}arr[N];
struct Edge
{
	LL y, v;
};
vector<Edge>edge[N];
LL cmp(node a, node b)
{
	return a.v < b.v;
}
void dfs(int u)
{
	for (auto x : edge[u]) {
		if (!dis[x.y]) {
			dis[x.y] = dis[u] + 1;
			f[x.y][0] = u;
			v[x.y][0] = x.v;
			dfs(x.y);
		}
	}
}
int main()
{
	scanf("%lld%lld", &n, &m);
	for (LL i = 1; i <= m; i++) {
		LL a, b, v;
		scanf("%lld%lld%lld", &a, &b, &v);
		arr[i] = { a,b,v };
		arr[i].id = i;
	}
	for (LL i = 1; i <= n; i++)p[i] = i;
	sort(arr + 1, arr + m + 1, cmp);
	LL ans = 0;
	for (LL i = 1; i <= m; i++) {
		LL a = find(arr[i].a);
		LL b = find(arr[i].b);
		if (a != b) {
			ans += arr[i].v;
			p[a] = b;
			edge[arr[i].a].push_back({ arr[i].b ,arr[i].v });
			edge[arr[i].b].push_back({ arr[i].a,arr[i].v });
		}
	}
	memset(dis, 0, sizeof(dis));
	dis[1] = 1;
	dfs(1);
	for (LL i = 1; i <= n; i++) {
		for (LL j = 1; j < 21; j++) {
			f[i][j] = f[f[i][j - 1]][j - 1];
			v[i][j] = max(v[i][j - 1], v[f[i][j - 1]][j - 1]);
		}
	}
	for (LL i = 1; i <= m; i++) {
		LL x = arr[i].a;
		LL y = arr[i].b;
		if (dis[x] < dis[y]) swap(x, y);
		LL d = dis[x] - dis[y];
		LL sum = 0;
		for (LL i = 0; d; i++) {
			if (d & 1) {
				sum = max(sum, v[x][i]);
				x = f[x][i];
			}
			d /= 2;
		}
		if (x != y) {
			for (LL i = 20; i >= 0; i--) {
				if (f[x][i] != f[y][i]) {
					sum = max(sum, v[x][i]);
					sum = max(sum, v[y][i]);
					x = f[x][i];
					y = f[y][i];
				}
			}
			sum = max(sum, v[x][0]);
			sum = max(sum, v[y][0]);
		}     
		res[arr[i].id] = ans;
		res[arr[i].id] -= sum;
		res[arr[i].id] += arr[i].v;
	}
	for (LL i = 1; i <= m; i++) {
		printf("%lld\n", res[i]);
	}
	return 0;
}